#!/usr/bin/perl



$LOG_FILE1='/LOGS/tuxedolog/stdoutlog/eai2host130.out';
$LOG_FILE2='/LOGS/tuxedolog/stdoutlog/host2eai130.out';

sub is_in_errlist
{
	local( $err_msg ) = @_;
#print "is_in_errlist($err_msg) \n";
	$i = 1;
	while( $err_list[$i] ){
		#print "-$i-";
		if( $err_list[$i] eq $err_msg ){
			return($i);
		}
		$i += 1;
	}
	return(0);
}

$cmd="grep fail $LOG_FILE1 > /tmp/errlist.txt";
!system($cmd);
$cmd="grep fail $LOG_FILE2 >> /tmp/errlist.txt";
!system($cmd);

$err_cnt=0;
open(LOG_FILE, "< /tmp/errlist.txt");
while( $line = <LOG_FILE> ) {
	chop $line;
	@val1 = split '>', $line;
	#@val2 = split 'fail', $val1[3];
	#print "$val1[0]|$val1[2]|$val1[3]\n";

	$err_list_idx = is_in_errlist( $val1[3] );
	if( $err_list_idx == 0 ){
		$err_cnt += 1;

		$err_list[$err_cnt] = $val1[3];
		$err_st_time[$err_cnt] = $val1[0];
		$err_en_time[$err_cnt] = $val1[0];
		$err_kind_cnt[$err_cnt] += 1;
	}
	$err_en_time[$err_list_idx] = $val1[0];
	$err_kind_cnt[$err_list_idx] += 1;
}

print "Error List (errcnt: $err_cnt)\n";
$i = 1;
while( $i <= $err_cnt ) {
	print "*$i:<$err_list[$i]><cnt:$err_kind_cnt[$i]>$err_st_time[$i]>$err_en_time[$i]>\n";
	$i += 1;
}
